package com.departmentstore.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.util.Set;

@Data
@Entity
@Table(name = "product")
public class Product {
    @Id
    @Column(name = "product_id", length = 10)
    @NotBlank(message = "商品ID不能为空")
    @Size(min = 1, max = 10, message = "商品ID长度必须在1-10之间")
    private String productId;

    @Column(name = "name", length = 50)
    @NotBlank(message = "商品名称不能为空")
    @Size(min = 1, max = 50, message = "商品名称长度必须在1-50之间")
    private String name;

    @Column(name = "model", length = 20)
    private String model;

    @Column(name = "base_price", precision = 10, scale = 2)
    private BigDecimal basePrice;

    @Column(name = "category", length = 50, nullable = true)
    private String category;

    @Column(name = "price", precision = 10, scale = 2)
    private BigDecimal price;

    @Column(name = "description", length = 500, nullable = true)
    private String description;

    @OneToMany(mappedBy = "product", fetch = FetchType.LAZY)
    @JsonIgnore
    private Set<DepartmentProduct> departmentProducts;

    @OneToMany(mappedBy = "product", fetch = FetchType.LAZY)
    @JsonIgnore
    private Set<ManufacturerProduct> manufacturerProducts;
} 